package com.example.kt_base.s6

//TODO 105.Kotlin语言的泛型函数
class KtBase105<T>(private val isR:Boolean,private val obj:T){
    fun getObj()=obj.takeIf { isR }

}
fun main() {
    val stu1=Student("liMing")
    val tea=Teacher("he")

    println(KtBase105(false, stu1).getObj())
    println(KtBase105(true, tea).getObj())
    show(stu1)
}

fun <T> show(item:T){
    item?.also {
        println(item)
    }?: println("返回null")
}